﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Read.Api.Application.Command.Processiings_CompanyWay;

namespace Traceability_Management.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Processiings_CompanyWayController : ControllerBase
    {
        IMediator mediator;

        public Processiings_CompanyWayController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<ApiResult<int>> AddFourWayAll(Processiings_Company Processiings_Company)
        {
            try
            {
                AddProcessiings_CompanyWayCommand AddProcessiings_CompanyWayCommand = new AddProcessiings_CompanyWayCommand()
                {
                    Processiings_Company = Processiings_Company
                };
                return await mediator.Send(AddProcessiings_CompanyWayCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<Processiings_Company>> FirstNextSlaughts([FromQuery] FirstProcessiings_CompanyCompanyWayCommand FirstProcessiings_CompanyCompanyWayCommand)
        {
            try
            {
                return await mediator.Send(FirstProcessiings_CompanyCompanyWayCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdateNextSlaughts(Processiings_Company Processiings_Company)
        {
            try
            {
                UpdateProcessiings_CompanyWayCommand UpdateProcessiings_CompanyWayCommand = new UpdateProcessiings_CompanyWayCommand()
                {
                    Processiings_Company = Processiings_Company
                };
                return await mediator.Send(UpdateProcessiings_CompanyWayCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
